home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 6 / PC World Interactive 6.iso / online / twsk21c.EXE / LOGIN.CMD < prev    next >
OS/2 REXX Batch file  |  1995-06-14  |  4KB  |  182 lines

  1. #
  2. #  Trumpet Winsock 2.1 Login.cmd
  3. #
  4. #  Copyright (C) 1994,1995 Peter R. Tattam & 
  5. #  Trumpet Software International Pty Ltd (TSI)
  6. #  All rights reserved.
  7. #
  8. #  Unless TSI has given prior written consent to such use, 
  9. #  no permission is granted to distribute or otherwise make available 
  10. #  to the public modified versions of this script for commercial purposes.  
  11. #  Any permitted distribution of modified versions of the script must
  12. #  retain the copyright notice at the start of this file and must clearly 
  13. #  identify those parts of the file which have been modified.
  14. #
  15. #trace on
  16. #
  17. # set up some strings for dialling up
  18. #
  19. if ![load $number]
  20.   if [query $number "Enter your dial up phone number"]
  21.     save $number
  22.   end
  23. end
  24. if ![load $username]
  25.   if [username "Enter your login username"]
  26.     save $username
  27.   end
  28. end
  29. if ![load $password]
  30.   if [password "Enter your login password"]
  31.     save $password
  32.   end
  33. end
  34. $modemsetup = "&c1&k3"
  35. $prompt = ">"
  36. $userprompt = "sername:"
  37. $passprompt = "assword:"
  38. $slipcmd = "cslip"
  39. $addrtarg = "our address is"
  40. $pppcmd = "ppp"
  41. $pppready = "PPP."
  42. %attempts = 10
  43.  
  44. ###############################################
  45. # timeouts for various sections of the script #
  46. ###############################################
  47. #
  48. # timeout for busy tone... adjust this until the BUSY string is detected.
  49. #
  50. %busytimeout = 10
  51. #
  52. # time between successive busy attempts.
  53. #
  54. %busywait = 30
  55. #
  56. # time to wait for a CONNECT string to be received
  57. #
  58. %connecttimeout = 60
  59. #
  60. # time to wait until DCD is detected
  61. #
  62. %onlinetimeout = 60
  63. #
  64. # time to wait for username & password prompts
  65. #
  66. %logintimeout = 60
  67. #
  68. # time to wait for server prompt to appear
  69. #
  70. %prompttimeout = 30
  71. #
  72. # time to wait for a SLIP address to be parsed
  73. #
  74. %addresstimeout = 30
  75. #
  76. #
  77. #
  78. #
  79. #----------------------------------------------------------
  80. #
  81. # initialize modem
  82. #
  83. status "Initializing modem..."
  84. output "atz"\13
  85. if ! [input 5 OK\n]
  86.   message "Modem is not responding"
  87.   abort
  88. end
  89. #
  90. # setup our modem commands
  91. #
  92. output "at"$modemsetup\13
  93. if ! [input 10 OK\n]
  94.   message "Modem is not responding"
  95.   abort
  96. end
  97. #
  98. # send phone number
  99. #
  100. %n = 0
  101. repeat
  102.   %n = %n + 1
  103.   if %n > %attempts
  104.     message "Too many dial attempts"
  105.     abort
  106.   end
  107.   status Dialling $number...(attempt %n)
  108.   output "atdt"$number\13
  109.   %busy = [input %busytimeout BUSY]
  110.   if %busy
  111.     status "The line is busy...pausing for a while"
  112.     sleep %busywait
  113.     %ok = 0
  114.   else
  115.     %ok = [input %connecttimeout CONNECT]
  116.   end
  117. until %ok
  118. input 10 \n
  119. #
  120. #  wait till it's safe to send because some modem's hang up
  121. #  if you transmit during the connection phase
  122. #
  123. wait %onlinetimeout dcd
  124. status Connected.  Now logging in as $username...
  125. #
  126. # now prod the terminal server
  127. #
  128. #output \13
  129. #
  130. #  wait for the username prompt
  131. #
  132. input %logintimeout $userprompt
  133. output $username\13
  134. #
  135. # and the password
  136. #
  137. input %logintimeout $passprompt
  138. output $password\13
  139. #
  140. # we are now logged in
  141. #
  142. status "Logged in. Now switching to Internet..."
  143. input %prompttimeout $prompt
  144. if %ppp
  145.   #
  146.   # jump into ppp mode
  147.   #
  148.   output $pppcmd\13
  149.   #
  150.   # wait for PPP prompt.
  151.   input %prompttimeout $pppready
  152.   #
  153.   display \n\n"PPP mode selected.  Will try to negotiate IP address."\n
  154.   status "PPP mode selected.  Will try to negotiate IP address."
  155.   sleep 1
  156.   #
  157. else
  158.   #
  159.   # jump into slip mode
  160.   #
  161.   output $slipcmd\13
  162.   #
  163.   # wait for the address string
  164.   #
  165.   input %addresstimeout $addrtarg
  166.   #
  167.   # parse address
  168.   #
  169.   address 30
  170.   input %addresstimeout \n
  171.   #
  172.   # we are now connected, logged in and in slip mode.
  173.   #
  174.   display \n
  175.   display Connected.  Your IP address is \i.\n
  176.   status Connected.  Your IP address is \i.
  177.   sleep 1
  178. end
  179. #
  180. # now we are finished.
  181. #
  182.